package de.openkanban.server.session;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Component;

@Component
public class OpenKanbanSessionAttributes {

	public final static String ATTR_NAME_USERID = "userId";

	public Long getUserId(HttpServletRequest request) {
		if (sessionExists(request)) {
			return (Long) request.getSession().getAttribute(ATTR_NAME_USERID);
		}
		return null;
	}

	private boolean sessionExists(HttpServletRequest request) {
		return request != null && request.getSession() != null;
	}

}
